<template>
  <div v-if="hasError" class="config-error">
    <div class="error-content">
      <i class="error-icon">⚠️</i>
      <h2>配置加载失败</h2>
      <p>请检查配置文件格式是否正确</p>
    </div>
  </div>
  <slot v-else></slot>
</template>

<script setup>
import { ref, onErrorCaptured } from 'vue'

const hasError = ref(false)

onErrorCaptured((err) => {
  if (err.message.includes('config')) {
    hasError.value = true
    return false
  }
})
</script>

<style lang="scss" scoped>
.config-error {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background-color);
  z-index: 9999;

  .error-content {
    text-align: center;
    padding: 2rem;

    .error-icon {
      font-size: 4rem;
      margin-bottom: 1rem;
    }

    h2 {
      font-size: 1.5rem;
      color: #f44336;
      margin-bottom: 1rem;
    }

    p {
      color: var(--text-color);
      opacity: 0.8;
    }
  }
}
</style> 